package com.wasu.sdk_ott.provider

import android.content.UriMatcher
import android.net.Uri

/**
 * <p>------------------------------------------------------
 * <p>Copyright (C) 2020 wasu company, All rights reserved.
 * <p>------------------------------------------------------
 * <p> 在 WasuSdkProvider query中匹配
 * <p>
 *
 * @author Created by zhangmz
 * @date on 2023/8/23
 */

/**
 * 注册的 authorities
 */
const val WASU_SDK_PROVIDER_URI = "com.wasu.live.data.provider"

/**
 * 外部调用cp的base uri
 */
val BASE_URI: Uri = Uri.parse("content://$WASU_SDK_PROVIDER_URI")

/**
 * 匹配接口
 * @see WasuSdkModuleProvider 中使用
 */
fun buildUriMatcher(): UriMatcher {

    return UriMatcher(UriMatcher.NO_MATCH).apply {

        // 分组频道节目单
        addURI(WASU_SDK_PROVIDER_URI, PATH_WASU_SDK_IPLIVE_CHANNEL_GROUP, CODE_WASU_SDK_IPLIVE_CHANNEL_GROUP)
        addURI(WASU_SDK_PROVIDER_URI, PATH_WASU_SDK_IPLIVE_CHANNEL_TIMESHIFT, CODE_WASU_SDK_IPLIVE_CHANNEL_TIMESHIFT)
        addURI(WASU_SDK_PROVIDER_URI, PATH_WASU_SDK_IPLIVE_PROGRAM, CODE_WASU_SDK_IPLIVE_PROGRAM)
        addURI(WASU_SDK_PROVIDER_URI, PATH_WASU_SDK_IPLIVE_CHANNEL, CODE_WASU_SDK_IPLIVE_CHANNEL)
        addURI(WASU_SDK_PROVIDER_URI, PATH_WASU_SDK_IPLIVE_CHANNEL_PURCHASED, CODE_WASU_SDK_IPLIVE_CHANNEL_PURCHASED)

        // 频道收藏
        addURI(WASU_SDK_PROVIDER_URI, FAVORITES_DB_PATH, CODE_WASU_SDK_COLLECT_CHANNEL)
        // 节目单预约
        addURI(WASU_SDK_PROVIDER_URI, RESERVATION_DB_PATH, CODE_WASU_SDK_RESERVATION_PROGRAM)
        // 分组频道节目单版本号
        addURI(WASU_SDK_PROVIDER_URI, LIVE_VERSION_DB_PATH, CODE_WASU_SDK_LIVE_VERSION)

    }
}

//////////////////////////////////////////////////////////////////////////////

/**
 * 回调结果
 */
const val RESULT_WASU_SDK_IPLIVE = "wasu_module_sdk_iplive_result"
/**
 * 分组频道列表
 */
const val PATH_WASU_SDK_IPLIVE_CHANNEL_GROUP = "wasu_sdk_path_iplive_channel_group"
/**
 * 分组频道列表
 */
const val PATH_WASU_SDK_IPLIVE_CHANNEL_TIMESHIFT = "wasu_sdk_path_iplive_channel_timeshift"
/**
 * 单个频道信息
 */
const val PATH_WASU_SDK_IPLIVE_CHANNEL = "wasu_sdk_path_iplive_channel"
/**
 * 查询某个频道是否授权
 */
const val PATH_WASU_SDK_IPLIVE_CHANNEL_PURCHASED = "wasu_sdk_path_iplive_channel_purchased"
/**
 * 节目单
 */
const val PATH_WASU_SDK_IPLIVE_PROGRAM = "wasu_sdk_path_iplive_program"

/**
 * 分组频道列表
 */
const val CODE_WASU_SDK_IPLIVE_CHANNEL_GROUP = 1000
/**
 * 时移频道列表
 */
const val CODE_WASU_SDK_IPLIVE_CHANNEL_TIMESHIFT = CODE_WASU_SDK_IPLIVE_CHANNEL_GROUP + 1
/**
 * 单个频道信息
 */
const val CODE_WASU_SDK_IPLIVE_CHANNEL = CODE_WASU_SDK_IPLIVE_CHANNEL_TIMESHIFT + 1
/**
 * 频道授权信息信息
 */
const val CODE_WASU_SDK_IPLIVE_CHANNEL_PURCHASED = CODE_WASU_SDK_IPLIVE_CHANNEL + 1
/**
 * 查询节目单
 */
const val CODE_WASU_SDK_IPLIVE_PROGRAM = CODE_WASU_SDK_IPLIVE_CHANNEL_PURCHASED + 1

//////////////////////////////////////////////////////////////////////////////

/**
 * 收藏结果回调
 */
const val RESULT_WASU_SDK_COLLECT = "live_favorites_channel_result"

/**
 * 收藏uri
 */
const val FAVORITES_DB_PATH = "live_favorites_channel_path"

/**
 * 频道收藏
 */
const val CODE_WASU_SDK_COLLECT_CHANNEL = CODE_WASU_SDK_IPLIVE_CHANNEL_GROUP + 1000

/**
 * 频道收藏保存uri全路径
 */
val FAVORITES_CONTENT_URI: Uri = BASE_URI.buildUpon().appendPath(FAVORITES_DB_PATH).build()

/**
 * db排序条件入参
 */
const val FAVORITES_SORT_ASC = "date ASC"

/**
 * db排序条件入参
 */
const val FAVORITES_SORT_DESC = "date DESC"

//////////////////////////////////////////////////////////////////////////////

/**
 * 节目单预约条件，1分钟，距离开始小于这个时间，不会预约成功
 */
const val RESERVATION_CONDITION = 60000

/**
 * 预约uri
 */
const val RESERVATION_DB_PATH = "live_schedual_edit_path"

/**
 * 预约节目单插入
 */
const val CODE_WASU_SDK_RESERVATION_PROGRAM = CODE_WASU_SDK_COLLECT_CHANNEL + 1000

/**
 * 节目单预约保存uri全路径
 */
val RESERVATION_CONTENT_URI: Uri = BASE_URI.buildUpon().appendPath(RESERVATION_DB_PATH).build()

/**
 * db排序条件
 */
const val RESERVATION_SORT = "startdate ASC"

//////////////////////////////////////////////////////////////////////////////

/**
 * 分组频道节目单版本号
 */
const val LIVE_VERSION_DB_PATH = "wasu_version_info_path"

/**
 * 分组频道节目单版本号本地数据库保存
 */
const val CODE_WASU_SDK_LIVE_VERSION = CODE_WASU_SDK_RESERVATION_PROGRAM + 1000

/**
 * 分组频道节目单版本号保存uri全路径
 */
val LIVE_VERSION_CONTENT_URI: Uri = BASE_URI.buildUpon().appendPath(LIVE_VERSION_DB_PATH).build()


//////////////////////////////////////////////////////////////////////////////

/**
 * 以下两个是调用sdk插件cp的路径
 */
const val PATH_WASU_SDK_CONTENT_AUTHORITY = "com.wasu.launcher.SDK.Plugin.0"
const val PATH_WASU_SDK_PLUGIN_AUTHORITY = "com.wasu.plugin.sdk"

/**
 * 4K网关鉴权IP频道授权接口
 */
const val PATH_LIVE_UNIFIED_AUTH = "wasu_unified_auth_getauth"

/**
 * 4K网关鉴权IP频道授权接口结果
 */
const val RESULT_LIVE_UNIFIED_AUTH = "wasu_unified_auth_system_result"
//////////////////////////////////////////////////////////////////////////////

/////////////////////////////// 以下是讯飞用的 //////////////////////////////////

/**
 * 分组频道
 */
const val LAUNCHER_GET_IP_BOUCH = "LAUNCHER_GET_IP_BOUCH"

/**
 * 节目单
 */
const val LAUNCHER_GET_EPG_Q = "LAUNCHER_GET_EPG_Q"

/**
 * 频道授权
 */
const val LAUNCHER_GET_CHANNEL_PURCHASED = "LAUNCHER_GET_CHANNEL_PURCHASED"

const val LAUNCHER_VERSION = "LAUNCHER_VERSION"

/**
 * 回调给讯飞是否在直播(live)/点播(vod)/其他(other)
 */
const val LAUNCHER_SCENE_POS = "LAUNCHER_SCENE_POS"

/////////////////////////////// 以上是讯飞用的 //////////////////////////////////
//////////////////////////////////////////////////////////////////////////////

